package com.llb666.shop.user.api.dto;

import com.llb666.shop.user.domain.entity.UserAddress;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

/**
 * 用户地址dto
 *
 * @author llb666
 */
@Data
@Schema(name = "UserAddressDto", description = "用户地址对象，新增修改接口使用")
public class UserAddressDto {

    @Schema(description = "地址主键id", name = "addressId")
    private String addressId;

    @Schema(description = "关联用户id", name = "userId")
    private String userId;

    @Schema(description = "收件人姓名")
    private String receiver;

    @Schema(description = "收件人手机号")
    private String mobile;

    @Schema(description = "省份")
    private String province;

    @Schema(description = "城市")
    private String city;

    @Schema(description = "区县")
    private String district;

    @Schema(description = "详细地址")
    private String detail;

    @Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
    public interface Converter {
        Converter INSTANCE = Mappers.getMapper(UserAddressDto.Converter.class);

        @Mapping(source = "addressId", target = "id")
        UserAddress dto2do(UserAddressDto activity);
    }
}
